package cn.livingCloud.service.impl.operation;

import cn.livingCloud.dto.ButtonDto;
import cn.livingCloud.dto.ButtonListDto;
import cn.livingCloud.entity.content.Button;

import java.util.List;

/**
 * Created by sujiantang on 2016/1/8.
 */
public class ButtonListDtoLoader extends ButtonTreeLoader {

    private ButtonListDto listDto;

    public ButtonListDtoLoader(ButtonListDto listDto) {
        this.listDto = listDto;
    }

    public void load() {
        List<Button> list = super.loadTree();
        List<ButtonDto> buttonList = listDto.getButtonList();
        for (Button button : list) {
            buttonList.add(new ButtonDto(button));
        }
        if (list.size() >= 3) {
            listDto.setShowAdd(false);
        } else {
            listDto.setShowAdd(true);
        }
    }
}
